<template>
  <div class="card-box">
    <div class="home-title">项目预警点</div>
    <div class="warning-table">
      <el-table
        height="100%"
        :header-cell-style="{
          background: 'rgb(217,236,255)',
          color: '#409EFF',
          height: '50px',
        }"
        :data="listData"
        stripe
      >
        <el-table-column label="预警类型" width="50" align="center">
          <template slot-scope="scope">
            <i
              :style="{
                color: scope.row.warning_level == 1 ? '#E6A23C' : '#F56C6C',
              }"
              class="iconfont icon-largecircle_fill_circle"
            ></i>
          </template>
        </el-table-column>

        <el-table-column
          v-for="(col, index) in columns"
          :prop="col.prop"
          :key="'bs_' + index"
          :label="col.label"
          :width="col.width"
          :min-width="col.minWidth || '0'"
          :align="col.align || 'center'"
          :fixed="col.fixed"
        >
          <template slot-scope="scope">
            <span v-if="col.prop == 'description'">
              <el-popover trigger="hover" placement="top">
                <div>
                  {{ scope.row[col.prop] }}
                </div>
                <div slot="reference" class="name-wrapper">
                  <el-tag type="danger" size="mini">预警规则</el-tag>
                </div>
              </el-popover>
            </span>
            <span v-else>
              {{ scope.row[col.prop] }}
            </span>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    listData: {
      type: Array,
      default: null,
    },
  },
  data() {
    return { columns: columns, info: null };
  },
  methods: {},
  watch: {
    listData(newVal) {
      if (newVal) {
      }
    },
  },
};
const columns = [
  {
    prop: "object_name",
    label: "项目名称",
    width: "",
    minWidth: "200",
    align: "",
  },
  {
    prop: "sub_scene",
    label: "预警节点",
    width: "",
    minWidth: "130",
    align: "",
  },
  {
    prop: "description",
    label: "预警规则",
    width: "100",
    minWidth: "",
    align: "",
  },
  // {
  //   prop: "",
  //   label: "责任单位",
  //   width: "",
  //   minWidth: "130",
  //   align: "",
  // },
  // {
  //   prop: "type",
  //   label: "完成状态",
  //   width: "100",
  //   minWidth: "",
  //   align: "",
  // },
  {
    prop: "trigger_time",
    label: "预警时间",
    width: "100",
    minWidth: "",
    align: "",
  },
];
</script>

<style lang="scss" scoped>
@import "./home.scss";
.card-box {
  height: 100%;
}
.warning-table {
  margin-top: 10px;
  height: calc(100% - 50px);
  overflow-y: auto;
}
</style>